[XEND] Check for invalid memory sizes.
authoratse@norwich.uk.xensource.com <atse@norwich.uk.xensource.com>
Fri, 22 Sep 2006 14:36:11 +0000 (15:36 +0100)
committeratse@norwich.uk.xensource.com <atse@norwich.uk.xensource.com>
Fri, 22 Sep 2006 14:36:11 +0000 (15:36 +0100)
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
tools/python/xen/xend/XendDomainInfo.py

index 598efc7c918ad9316f9a5da9942f0448ae1d0f98..f47d9303490a3506fdd84aeef0343753f549304a 100644 (file)
@@ -596,6 +596,8 @@ class XendDomainInfo:
             if self.info['memory'] == 0:
                 if self.infoIsSet('mem_kb'):
                     self.info['memory'] = (self.info['mem_kb'] + 1023) / 1024
+            if self.info['memory'] <= 0:
+                raise VmError('Invalid memory size')
 
             if self.info['maxmem'] < self.info['memory']:
                 self.info['maxmem'] = self.info['memory']
@@ -1001,6 +1003,9 @@ class XendDomainInfo:
         """Set the memory target of this domain.
         @param target In MiB.
         """
+        if target <= 0:
+            raise XendError('Invalid memory size')
+        
         log.debug("Setting memory target of domain %s (%d) to %d MiB.",
                   self.info['name'], self.domid, target)